<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <link rel="stylesheet" href="/Album/Public/css/bootstrap.min.css"/>
    <script src="/Album/Public/js/jquery.js"></script>
    <script src="/Album/Public/js/bootstrap.min.js"></script>
    
        <link rel="stylesheet"  href="/Album/Public/css/style.css"/>
    
</head>
<body>
<!-- header -->
<header class="header">
    <span>微型相册系统</span>
</header>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand"  href="<?php echo U('Index/main');?>">主页</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="<?php echo U('Login/outlogin');?>">退出</a></li>
                    <li>
                        <a data-toggle="modal" data-target="#myModal">添加相册</a>
                    </li>
                    <li>
                        <a  href="<?php echo U('Index/index');?>" data-toggle="modal" data-target="#myModal">相册</a>
                    </li>
                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>

    <div class="panel panel-info">
        <div class="panel-heading">
            相册系统
        </div>
            <div class="panel-body">
                <?php if(empty($list)): ?><div style="margin-top:150px;font-size:50px;margin-left:35%;height:200px;">没有相册</div>
                <?php else: ?>
                <?php if(is_array($list)): foreach($list as $key=>$val): ?><div class="col-xs-12 col-sm-6 col-md-4" >
                            <div class="thumbnail">
                                <img src="/Album<?php echo ($val['face']); ?>" alt="...">
                                <div class="caption">
                                    <h3><?php echo ($val['name']); ?></h3>
                                    <p><a  class="btn btn-primary" role="button" pid="<?php echo ($val['id']); ?>" >进入相册</a> <a  class="btn btn-default" role="button" data-toggle="modal" data-target="#myModal4" ><input type="hidden" value="<?php echo ($val['id']); ?>">添加图片</a></p>
                                </div>
                            </div>
                    </div><?php endforeach; endif; endif; ?>
            </div>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">Album</h4>
                </div>
                <div class="modal-body">
                    <form method="post" action="<?php echo U('Index/doalbum');?>" enctype="multipart/form-data">
                        <div class="form-group">
                            <label for="exampleInputEmail1">相册名</label>
                            <input type="text" class="form-control" id="exampleInputEmail1" name="name" >
                        </div>
                        <div class="form-group">
                            <label for="exampleInputFile">文件</label>
                            <input type="file" id="exampleInputFile" name="pic">
                        </div>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">Photo</h4>
                </div>
                <div class="modal-body">
                    <form method="post" action="<?php echo U('Index/photo');?>" enctype="multipart/form-data" >
                        <input type="hidden" id="pict" name="aid"/>
                        <div class="form-group">
                            <label for="exampleInputFile">文件</label>
                            <input type="file" id="exampleInputFile1" name="pic">
                        </div>
                        <button type="submit" class="btn btn-primary" >提交</button>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <script>
        $('.panel-body').find('[pid]').click(function ()
        {
              var pid=($(this).attr('pid'));
              $.ajax({
                type:'POST',
                url:"<?php echo U('Index/intophoto');?>",
                data:{'pid':pid},
                datatype:'string',
                success:function(msg){
                 $('.panel-heading').parent().replaceWith(msg);
                }
            })
        })
        $('.panel-body').find('[pid]').next().click(function () {
            var bid = ($(this).find('[value]').attr('value'));
            $('#pict').val(bid);
        })
        function func() {
            var bid = $('.panel-body').find('[aid]').attr('aid');
            $('#pict').val(bid);
        }
    </script>



</body>
</html>